def process_code(code):
    variables = {'a': 0, 'b': 0, 'c': 0}
    lines = code.split(';')
    for line in lines:
        if line:
            parts = line.split(':=')
            if len(parts) == 2:
                var = parts[0].strip()
                value = parts[1].strip()
                if value.isdigit() and len(value) == 1:
                    variables[var] = int(value)
                elif value in variables:
                    variables[var] = variables[value]
    return variables['a'], variables['b'], variables['c']


input_code = input()
print(*process_code(input_code))


